<?php
namespace addons\csmtable\library;

use think\App;
use think\Loader;
use think\Request;
use app\common\controller\Backend;

abstract class ACsmgenerateControl extends Backend
{

    // protected $noNeedLogin = [
    //     '*'
    // ];

    protected $noNeedRight = [
        '*'
    ];

    protected $xlstaskdao = null;

    // config 配置
    protected $excelmaxrecoredcount = null;
    protected $controlpagesize = null;
    
    protected $uploadtmppath = RUNTIME_PATH . 'temp' . DS;

    public function _initialize()
    {
        parent::_initialize();
        $this->xlstaskdao = new \app\admin\model\csmtable\Xlstask();
        $config = get_addon_config("csmtable");
        $this->excelmaxrecoredcount = (int)$config["excelmaxrecoredcount"];
        $this->controlpagesize = $config["controlpagesize"];
    }
    // 获取记录数
    public function getDataRecordTotal(&$params)
    {
        $controlData = CsmTableUtils::callRemoteControl($params, 0, 1);
        return $controlData->getData()['total'];
    }

    public function getXlstaskParams($id)
    {
        $xlstaskrow = $this->xlstaskdao->where('id', '=', $id)->find();
        if ($xlstaskrow == null) {
            return;
        }
        return json_decode($xlstaskrow->param, true);
    }

    public static function p($str)
    {
        trace($str); 
        //echo($str."<BR>");
    }
    
}